//
//  analysis.m
//  Daily Watch
//
//  Created by 安静的美男子 on 14-10-14.
//  Copyright (c) 2014年 安静的美男子. All rights reserved.
//

#import "analysis.h"

@implementation analysis

-(void)dealloc
{
    [_dataSource release];
    [super dealloc];
    
}

-(void)sendBlock:(VideoBlock)block
{
    self.block = block;
}
-(void)Analysis
{
    self.dataSource = [NSMutableArray array];
    
    AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];
    [manger GET:@"http://watch-cdn.idailywatch.com/api/list/video/zh-hans?page=1&ver=iphone&app_ver=9" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        for (NSDictionary *dic in responseObject) {
            VideoModel *model = [VideoModel modelWithTitle:[dic objectForKey:@"title"] type:[dic objectForKey:@"type"] cover_thumb:[dic objectForKey:@"cover_thumb"] cover:[dic objectForKey:@"cover"] pubdate:[dic objectForKey:@"pubdate"] author:[dic objectForKey:@"author"] source:[dic objectForKey:@"source"] link_website:[dic objectForKey:@"link_website"] link_video:[dic objectForKey:@"link_video"] link_wechat:[dic objectForKey:@"link_wechat"] link_share:[dic objectForKey:@"link_share"] summary:[dic objectForKey:@"summary"] content:[dic objectForKey:@"content"]];
            [_dataSource addObject:model];
            
        }
        self.block(_dataSource);
        NSLog(@"%@",_dataSource);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"错误");
    }];
   
    
}
@end
